Skip to content

Allow developer to add custom FeedGeneratorService implementations #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 13, 2025

Conversation

BenWhite27
Copy link
Contributor

@BenWhite27 BenWhite27 commented May 27, 2025

This PR allows package consumers to implement their own feed generators.

Key changes

  • Added a FeedGenerators Collection Builder and associated factory to allow consumers to specify additional generators in startup configuration.
  • Swapped FeedType enum implementation out to use the new collection and factory.
  • Added Id, DisplayName, and Format properties to IProductFeedGeneratorService in the same implementation style as Property Extractors
  • Feed Generators can choose to implement either an XML or Json feed leaving the other implementation as not implemented.
  • ProductFeedController updated to generate the correct feed type.
  • Added abstract base class for Feed Generators to aid developers.

For consideration

  • I'm not that familiar with the database and migrations side of things in this package. I've updated the MappingProfile to map the new FeedGeneratorId property of FeedSettings to the original database column FeedType. This should mean that existing GoogleMerchantFeeds will continue to work without changes but makes things a bit inconsistant, so perhaps a Migration here would be better?
  • The GoogleMerchantFeed could be split out into its own package now.
  • I've removed the default feed property mapping for the google feed in the front-end code. Perhaps we need to make a way for consumers to define their own default property mapping?

@umbracotrd
Copy link
Contributor

umbracotrd commented Jun 2, 2025

Wow @BenWhite27! I appreciate the amount of effort you put into this plugin. Right now, we're focusing on the release of 16 and Codegarden, so this PR won't be reviewed over the next couple of weeks. I'm sure we'll take a look at it after those events

@BenWhite27
Copy link
Contributor Author

No worries, hope Codegarden goes well!
Do you want me to mark it as ready to review or do you need to take a closer look at the approach I used first?

@umbracotrd
Copy link
Contributor

If you've finished then mark it as ready for review and I'll take a look later.

@BenWhite27 BenWhite27 marked this pull request as ready for review June 3, 2025 07:28
@BenWhite27 BenWhite27 force-pushed the feature/extendable-feed-generators branch from beedf25 to 3e86bb7 Compare July 11, 2025 15:35
@BenWhite27
Copy link
Contributor Author

Hi Dinh, Hope Codegarden went well!
Just an FYI, I've rebased this PR onto the v16 release. Happy to discuss the changes and make amendments if wanted.

@umbracotrd
Copy link
Contributor

Wonderful @BenWhite27 ! I've scheduled few days at the last week of July to review this one 💪

@umbracotrd umbracotrd requested a review from Copilot August 4, 2025 09:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR allows package consumers to implement their own feed generators by introducing a collection-based architecture for feed generation. The changes move away from a hardcoded enum-based approach to a flexible system where custom feed generators can be registered and used.

  • Introduced FeedGeneratorCollection and associated factory to allow registration of custom feed generators
  • Replaced ProductFeedType enum with string-based FeedGeneratorId for identifying generators
  • Added support for both XML and JSON feed formats through the new FeedFormat enum and corresponding generation methods

Reviewed Changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ProductFeedController.cs Updated to handle both XML and JSON feed generation based on generator format
ProductFeedSettingController.cs Modified to use the new feed generator collection instead of hardcoded enum values
IUmbracoCommerceBuilderExtensions.cs Added FeedGenerators collection builder and registered GoogleMerchantCenterFeedService
CustomRouting.cs Updated route action name from "Xml" to "Generate"
ProductFeedSettingsService.cs Updated validation to use feed generator collection instead of enum parsing
InfrastructureMappingProfile.cs Added mapping between FeedGeneratorId and database FeedType column
ProductFeedType.cs Removed enum file as it's replaced by collection-based approach
ProductFeedSettingWriteModelValidator.cs Updated validation to use FeedGeneratorId instead of FeedType
ProductFeedSettingWriteModel.cs Replaced FeedType property with FeedGeneratorId string property
ProductFeedSettingReadModel.cs Replaced FeedType property with FeedGeneratorId string property
ProductFeedGeneratorFactory.cs Refactored to use collection-based lookup instead of switch statement
GoogleMerchantCenterFeedService.cs Updated to inherit from base class and implement new interface properties
FeedGeneratorServiceBase.cs Added abstract base class to aid custom feed generator development
FeedGeneratorCollectionBuilder.cs Added collection builder for registering feed generators
FeedGeneratorCollection.cs Added collection class for feed generators
IProductFeedGeneratorService.cs Updated interface with Id, DisplayName, Format properties and separate XML/JSON methods
IProductFeedGeneratorFactory.cs Updated factory interface to accept string instead of enum
FeedFormat.cs Added enum for feed format types (Unknown, Xml, Json)
details.element.ts Updated frontend to use feedGeneratorId instead of feedType
types.ts Updated TypeScript types to use feedGeneratorId
context.ts Removed hardcoded Google Merchant Center property mappings from default state

@umbracotrd
Copy link
Contributor

umbracotrd commented Aug 4, 2025

Hi @BenWhite27 , overall the PR looks great. However, it creates a couple of breaking changes. I've fixed the IProductFeedGeneratorService.cs but can you look for other breaking changes and list them down?

Edit: Never mind, I'm going to add a task in the build pipeline to verify the breaking changes.

@BenWhite27
Copy link
Contributor Author

Great, Thanks for looking at this Dinh, apologies for the breaking changes, I think I had the mind set of this being part of a major release at the time and I'm not that used to writing library code. Let me know if there's anything else I can do.

@umbracotrd
Copy link
Contributor

Hi @BenWhite27 , I've double checked that there's no API breaking changes left by adding a bunch of obsolete properties and methods.

But, I've readded the default feed property mapping for the google feed in the front-end code because it's convenient and we have no alternatives for now.

Can you verify that your changes remains?

@BenWhite27
Copy link
Contributor Author

Thanks @umbracotrd I'll check ASAP

@BenWhite27
Copy link
Contributor Author

HI @umbracotrd
Looks like everything is still in place!
I'm still able to create a custom feed generator, add it to the collection builder, create it in the Backoffice and it still generates just fine via the view feed option.

Cheers
Ben

@umbracotrd umbracotrd merged commit 8a87b91 into umbraco:main Aug 13, 2025
1 check passed
@umbracotrd umbracotrd changed the title Allow custom FeedGeneratorService implementations Allow developer to add custom FeedGeneratorService implementations Aug 13, 2025
@umbracotrd
Copy link
Contributor

@BenWhite27 : great. I'll prepare the 16.1.0 and release it tomorrow

@BenWhite27
Copy link
Contributor Author

@umbracotrd Great news, thanks for putting the finishing touches on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants